#include "listitembox.h"
#include "ui_listitembox.h"
#include<QEvent>

ListItemBox::ListItemBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ListItemBox),
    IsLike(false)
{
    ui->setupUi(this);
}

ListItemBox::~ListItemBox()
{
    delete ui;
}

void ListItemBox::enterEvent(QEvent *event)
{
    (void)event;
    setStyleSheet("background-color:#EFEFEF");
}

void ListItemBox::leaveEvent(QEvent *event)
{
    (void)event;
   setStyleSheet("");
}

void ListItemBox::setMusicName(const QString &musicName)
{
   ui->musicNameLabel->setText(musicName);
}

void ListItemBox::setMusicSigner(const QString &musicSinger)
{
    ui->musicSingerLabel->setText(musicSinger);
}

void ListItemBox::setAlumnName(const QString &musicAlumnName)
{
    ui->albumNameLabel->setText(musicAlumnName);
}

void ListItemBox::setLikeICon(bool like)
{
    IsLike=like;
    if(IsLike==true)
    {
        ui->likeBtn->setIcon(QIcon(":/image/likebtn.png"));
    }
    else
    {
        ui->likeBtn->setIcon(QIcon(":/image/unlikebtn.png"));
    }
}



void ListItemBox::on_likeBtn_clicked()
{
    //当用户点击该按钮的时候,切换图标
    IsLike=!IsLike;
    setLikeICon(IsLike);

    //2:更新页面的歌曲
    emit setIsLike(IsLike);


}
